package br.com.basili.mb;
import java.io.Serializable;
import java.util.Locale;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;

@SessionScoped
@ManagedBean
public class I18N implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
 	private String locale = "pt";
	private Boolean bPortugues = false;
	private Boolean bIngles = true;
	
	public String changLangPt() {
		setLocale("pt");
		UIViewRoot root = FacesContext.getCurrentInstance().getViewRoot();
		root.setLocale(new Locale("pt"));
			bIngles = true;
			bPortugues = false;
		
		return root.getViewId();
	}

	public String changLangEn() {
		setLocale("en");
		UIViewRoot root = FacesContext.getCurrentInstance().getViewRoot();
		root.setLocale(new Locale("en"));
		bIngles = false;
		bPortugues = true;
		
		return root.getViewId();
	}
	
	public String getLocale() {
		return locale;
	}

	public void setLocale(String locale) {
		this.locale = locale;
	}

	public Boolean getbPortugues() {
		return bPortugues;
	}

	public void setbPortugues(Boolean bPortugues) {
		this.bPortugues = bPortugues;
	}

	public Boolean getbIngles() {
		return bIngles;
	}

	public void setbIngles(Boolean bIngles) {
		this.bIngles = bIngles;
	}
	
}
